package com.ruijiang.controller.vm_service;


import com.ruijiang.controller.ApiPrefix;
import com.ruijiang.dto.page.PageNameDto;
import com.ruijiang.entity.VmType;
import com.ruijiang.result.PageResult;
import com.ruijiang.service.VmService.VmTypeService;


import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Delete;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(ApiPrefix.VM_SERVICE+"/vmType")
@Slf4j
public class VmTypeController {


    @Autowired
    private VmTypeService vmTypeService;

    @GetMapping("/{typeId}")
    public VmType getByTypeId(@PathVariable Integer typeId){
        log.info("查询机型 id：{}", typeId);
        return vmTypeService.getByTypeId(typeId);
    }

    /**
     * 分页查询
     * @param dto
     * @return
     */
    @GetMapping("/search")
    public PageResult getPageList(PageNameDto dto){
        log.info("分页查询机型");
        return vmTypeService.getPageList(dto);
    }

    @PostMapping
    public Boolean saveVmType(@RequestBody VmType vmType){
        log.info("新增售货机类型");
        return vmTypeService.save(vmType);
    }

    @DeleteMapping("/{typeId}")
    public Boolean deleteById(@PathVariable String typeId){
        log.info("删除售货机类型");
        return vmTypeService.removeById(typeId);
    }



}
